#pragma once

#include "Types.h"
#include "DisplayStyle.h"
#include "MasksCollection.h"

void BitMaskImage(
	ByteImage & im, ///< preresized
	const BitMask & Mask, const size_point & From,
	DisplayStyle const & d);
void BlendWithBitMask(
	ByteImage & im, ///< preresized
	const BitMask & Mask, const size_point & From,
	DisplayStyle const & d);

class PaintingKey : public CacheKey
{
public:
	PaintingKey();
	void Merge(ByteImage & im, icache::nearby may_be_requested_later) const;
public: //item_id interface
	virtual bool equal(const CacheKey & i) const;
	virtual String name() const;
	virtual void serialize(std::ostream & o) const;
	virtual bool loadable() const { return true; }
	virtual void load(ByteImage & im) const;
	virtual bool requestable() const { return false; }
	virtual void request() const;
	virtual bool cache_on_disc() const { return false; }
public:
	DisplayStyle		m_Style;
	MasksCollection		m_MasksWithCombMode;
	FootageSPtr			m_pObjectFootage;
	Size				m_ObjectFrame;
	FootageSPtr			m_pBackgroundFootage;
	Size				m_BackgroundFrame;
};

typedef boost::shared_ptr<PaintingKey> PaintingKeySPtr;

/// returned image will contain requested information (image will either be taken from cache or painted), 
/// but its id may differ from p;
/// if image is painted during the call and RamPreview is true, it will be placed in cache
CachedImageSPtr GetPainting(PaintingKeySPtr const & p, icache::nearby may_be_requested_later, bool RAMPreview);
